<%@page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:1px;">
  <t:datagrid name="zyWarrantyPeriodList" onLoadSuccess="colorStyle"  sortName="sn" fitColumns="false" title="未处理的数据差异如下:" actionUrl="zyWarrantyPeriodController.do?differDatagrid" idField="id" fit="true" queryMode="group">
  	 <t:dgCol title="主键"			field="id"		hidden="true"  queryMode="single"  width="120"/>
		   <t:dgCol title="版本号"		field="version"				queryMode="single"	query="false"  width="60"/>
		   <t:dgCol title="上传日期"		field="importDate"	formatter="yyyy-MM-dd"		queryMode="single"	query="false"  width="80"/>
		   <t:dgCol title="序列号"		field="sn"	 	url="zyWarrantyPeriodController.do?goView&sn={sn}"	funname="view"	queryMode="single"	query="false"  width="85" />
		   <t:dgCol title="集群"			field="cluster"		queryMode="single"	query="false"  width="70"/>
		   <t:dgCol title="保修截止日"	field="endOfWarranty" formatter="yyyy-MM-dd"	queryMode="single"	query="false"  width="80"/>
		   <t:dgCol title="服务合同"	field="serviceContract"				queryMode="single"	query="false"  width="80"/>
		   <t:dgCol title="合同开始日"	field="startContractCoverage"	formatter="yyyy-MM-dd"		queryMode="single"	query="false"  width="80"/>
		   <t:dgCol title="合同结束日"		field="endContractCoverage"		formatter="yyyy-MM-dd"		queryMode="single"	query="false"  width="80"/>
		   
		   <t:dgCol title="集群"			field="clusterColour"	hidden="true"	queryMode="single"	query="false"  width="120"/>
		   <t:dgCol title="保修截止日"	field="endOfWarrantyrColour" hidden="true"	queryMode="single"	query="false"  width="120"/>
		   <t:dgCol title="服务合同"	field="serviceContractColour"	hidden="true"			queryMode="single"	query="false"  width="120"/>
		   <t:dgCol title="合同开始日"	field="startContractCoverageColour"	hidden="true"		queryMode="single"	query="false"  width="120"/>
		   <t:dgCol title="合同结束日"		field="endContractCoverageColour"	hidden="true"			queryMode="single"	query="false"  width="120"/>
		   <t:dgCol title="标识"		field="formFlag" hidden="true" width="120"/>
		   <t:dgCol title="变更类型"		field="type"				queryMode="single"	query="false" dictionary="<%=StaticValue.DIC_FILE_SET_TYPE %>" width="60"/>
		   <t:dgCol title="处理状态"		field="status"				queryMode="single"	query="false" dictionary="<%=StaticValue.DIC_FILE_SET_STATUS %>" width="60"/>
		   <t:dgCol title="操作" field="opt" width="40"/>
  		   <t:dgFunOpt title="处理" funname="handle(id)" exp="formFlag#eq#2" />
  		   <t:dgToolBar title="导入" icon="icon-put"   funname="importExcel" />
<%--  		   <t:dgToolBar title="##定时导入保期记录-仅供测试用##" icon="icon-add" url="zyWarrantyPeriodController.do?runTimeTask" funname="runTimeTask" />--%>
  </t:datagrid>
  </div>
</div>
<script>
function handle(id){
	$.dialog.confirm("确认处理？",function(r){
		if(r){
			$.ajax({
				url : "zyWarrantyPeriodController.do?doSetStatus",
				data : {
					"id" : id
					},
				cache : false,
				dataType : 'json',
				type : 'POST',
				success : function(data){
					if(data.success){
						reloadTable();
					}else{
						tip(data.msg);
					}
				}
			});
		}
	});
}

function colorStyle(){
	changeTergatColumnColor('clusterColour','red','zyWarrantyPeriodList','cluster','red');
	changeTergatColumnColor('endOfWarrantyrColour','red','zyWarrantyPeriodList','endOfWarranty','red');
	changeTergatColumnColor('serviceContractColour','red','zyWarrantyPeriodList','serviceContract','red');
	changeTergatColumnColor('startContractCoverageColour','red','zyWarrantyPeriodList','startContractCoverage','red');
	changeTergatColumnColor('endContractCoverageColour','red','zyWarrantyPeriodList','endContractCoverage','red');
}
/**
*tergatColumn 对比目标列
*value 对比值
*datagrId datagrId
*changeColumn 改变列
*color 改变颜色 
*/
function changeTergatColumnColor(tergatColumn,value,datagrId,changeColumn,color){
	var rows = $("#"+datagrId+"").datagrid('getRows');//获取所有的数据行
	 for (var i = 0; i < rows.length; i++) {
        var tergat= rows[i][''+tergatColumn+''];
        if(tergat==value){
        	$("td[field='"+changeColumn+"']").parent(".datagrid-row").eq(i).children("td[field='"+changeColumn+"']").css("color",color);
        }
     }  
}

function view(title,url){
	addOneTab("查看设备详细",url,"");
}
function importExcel(){
	createdetailwindow('基础数据导入', 'zyWarrantyPeriodController.do?uploadFile',470,150);
}
function runTimeTask(title,url){
	$.post(url,function(){
		tip("执行完毕");
	});
}
</script>
